home *** CD-ROM | disk | FTP | other *** search
- unit Outline1;
- { PC PLUS example program.
-
- A simple example of how to use the Delphi Outline component.
-
- This is an implementation of a sample project described in the
- Delphi Help System. We have merely added a few checks and error
- messages to the SpeedButton1Click method.
- }
- interface
-
- uses
- SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
- Forms, Dialogs, StdCtrls, Buttons, Grids, Outline;
-
- type
- TForm1 = class(TForm)
- Outline1: TOutline;
- Edit1: TEdit;
- Edit2: TEdit;
- SpeedButton1: TSpeedButton;
- Label1: TLabel;
- Label2: TLabel;
- Label3: TLabel;
- Label4: TLabel;
- procedure SpeedButton1Click(Sender: TObject);
- procedure Outline1Expand(Sender: TObject; Index: Longint);
- procedure Outline1Click(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
-
- var
- Form1: TForm1;
-
- implementation
-
- {$R *.DFM}
-
- procedure TForm1.SpeedButton1Click(Sender: TObject);
- var
- AddStr: string;
- AddIndex :LongInt;
- Code : Integer;
- begin
- AddStr := Edit1.Text;
- Val(Edit2.Text, AddIndex, Code);
- { Error during conversion to integer? }
- if Code <> 0 then
- MessageDlg('Invalid index number.', mtWarning, [mbOk], 0)
- else
- if AddIndex > Outline1.Lines.Count then
- MessageDlg('Index exceeds number of items in outline!',mtWarning, [mbOk], 0)
- else
- if Edit1.Text = '' then
- MessageDlg('Please enter text for this item.', mtWarning, [mbOk], 0)
- else
- Outline1.AddChild(AddIndex, AddStr);
- Label2.Caption := IntToStr(Outline1.SelectedItem);
- end;
-
- procedure TForm1.Outline1Expand(Sender: TObject; Index: Longint);
- begin
- Label2.Caption := IntToStr(Outline1.SelectedItem);
- end;
-
- procedure TForm1.Outline1Click(Sender: TObject);
- begin
- Label2.Caption := IntToStr(Outline1.SelectedItem);
- end;
-
- end.
-